//package org.javaboy.formlogin;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
//import org.springframework.security.web.util.matcher.OrRequestMatcher;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author 江南一点雨
// * @微信公众号 江南一点雨
// * @网站 http://www.itboyhub.com
// * @国际站 http://www.javaboy.org
// * @微信 a_java_boy
// * @GitHub https://github.com/lenve
// * @Gitee https://gitee.com/lenve
// */
//@Configuration
//public class SecurityConfig2 extends WebSecurityConfigurerAdapter {
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http.authorizeRequests()
//                .anyRequest().authenticated()
//                .and()
//                .formLogin()
//                .loginPage("/mylogin.html")
//                .loginProcessingUrl("/doLogin")
//                .defaultSuccessUrl("/index.html")
//                .failureHandler(new MyAuthenticationFailureHandler())
//                .usernameParameter("uname")
//                .passwordParameter("passwd")
//                .permitAll()
//                .and()
//                .logout()
//                .logoutRequestMatcher(new OrRequestMatcher(
//                        new AntPathRequestMatcher("/logout1", "GET"),
//                        new AntPathRequestMatcher("/logout2", "POST")))
//                .invalidateHttpSession(true)
//                .clearAuthentication(true)
//                .defaultLogoutSuccessHandlerFor((req,resp,auth)->{
//                    resp.setContentType("application/json;charset=utf-8");
//                    Map<String, Object> result = new HashMap<>();
//                    result.put("status", 200);
//                    result.put("msg", "使用 logout1 注销成功!");
//                    ObjectMapper om = new ObjectMapper();
//                    String s = om.writeValueAsString(result);
//                    resp.getWriter().write(s);
//                },new AntPathRequestMatcher("/logout1","GET"))
//                .defaultLogoutSuccessHandlerFor((req,resp,auth)->{
//                    resp.setContentType("application/json;charset=utf-8");
//                    Map<String, Object> result = new HashMap<>();
//                    result.put("status", 200);
//                    result.put("msg", "使用 logout2 注销成功!");
//                    ObjectMapper om = new ObjectMapper();
//                    String s = om.writeValueAsString(result);
//                    resp.getWriter().write(s);
//                },new AntPathRequestMatcher("/logout2","POST"))
//                .and()
//                .csrf().disable();
//    }
//}
